home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-08-14 | 2.6 KB | 92 lines | [TEXT/KAHL] |
- //
- // WList.c, source code for the WList dcmd
- //
- // Daniel Jibouleau, 25/7/94
- //
-
- #include "dcmd.h" // necessary to use 'dcmdGlue.c'
-
- /* Prototypes */
- void AppendNum2Hex (Str255 dest, long number, short n);
- void AppendString (Str255 dest, Str255 source);
-
- //
- // Entry point: must be labelled 'CommandEntry'
- //
-
- pascal void CommandEntry (dcmdBlock *pb)
- {
- switch (pb -> request) {
- case dcmdInit:
- /* Nothing to do at init */
- break;
- case dcmdHelp:
- /* Print out help text */
- dcmdDrawLine ("\pWList");
- dcmdDrawLine ("\p Shows the list of all windows in the current application.");
- break;
- case dcmdDoIt: {
- /* Do it: show all windows */
- WindowPeek w = WindowList; // window to display info about: first window
- Str255 s; // string to print
-
- /* Print header */
- dcmdDrawLine ("\p Address Title Kind Visible Hilite defProc refCon");
-
- while (w) { // loop
- Length (s) = 0; // start with an empty string
- AppendNum2Hex (s, (long) w, 8); // append window address
- s [++ Length (s)] = ' '; // append a space
-
- AppendString (s, *w -> titleHandle); // append window title
- while (Length (s) < 30)
- s [++ Length (s)] = ' '; // ajust columns
-
- if (w -> windowKind == userKind) // window
- AppendString (s, "\pwind ");
- else if (w -> windowKind == dialogKind) // dialog box
- AppendString (s, "\pdlog ");
- else { // other: print windowKind
- AppendNum2Hex (s, w -> windowKind, 4); // append
- s [++ Length (s)] = ' '; }
-
- AppendString (s, (w -> visible) ? "\ptrue " : "\pfalse "); // visible
- AppendString (s, (w -> hilited) ? "\ptrue " : "\pfalse "); // hilited
-
- AppendNum2Hex (s, (long) w -> windowDefProc, 8); // defProc
- s [++ Length (s)] = ' ';
- AppendNum2Hex (s, w -> refCon, 8); // refCon
- s [++ Length (s)] = ' ';
-
- dcmdDrawLine (s);
- w = w -> nextWindow; }
- break; }
- }
- }
-
- //
- // AppendNum2Hex: appends an hex number to string 's'. n specifies byte length (ex.: short=2, long=4)
- //
-
- void AppendNum2Hex (Str255 s, long number, short n)
- {
- short i;
-
- for (i = n; i >= 1; i --) {
- s [Length (s) + i] = "0123456789ABCDEF" [number % 16];
- number /= 16; }
-
- Length (s) += n;
- }
-
- //
- // AppendString: appends 'source' to the end of 'dest' string
- //
-
- void AppendString (Str255 dest, Str255 source)
- {
- BlockMove (source + 1, dest + 1 + Length (dest), Length (source));
- Length (dest) += Length (source);
- }
-
-